﻿using System.Linq;
using Microsoft.Xna.Framework;

namespace SpaceGame.Gameplay.AI.Behaviors
{
    /// <summary>
    /// Behavior responsible for searching for weapons.
    /// </summary>
    public class ArmorBehavior : Behavior
    {
        #region Properties
        /// <summary>
        /// Current known location of power up, if any.
        /// </summary>
        public Vector2? PowerUpLocation
        {
            get; private set;
        }
        #endregion

        #region Initialize
        public ArmorBehavior(IEntity ship) : base(ship) { }
        #endregion

        /// <summary>
        /// Control initiative towards power up in the map. 
        /// </summary>
        public bool CheckForPowerUps()
        {
            //check if there is a power up in the world
            var q = from entity in Entity.World.Entities
            where entity is PowerUp
            select entity;

            var powerUp = q.FirstOrDefault();

            if(powerUp == null)
            {
                PowerUpLocation = null;
                return false;
            }

            PowerUpLocation = powerUp.Position;

            return true;
        }
    }
}
